/*
 * Copyright (C) 2017 The MoonLake Authors
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */


package com.minecraft.moonlake.legendaryweaponrel.weapons.tool;

import com.minecraft.moonlake.legendaryweaponrel.weapons.WeaponAbstractEntityDamageByEntity;
import org.bukkit.Material;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;

public class Agni extends WeaponAbstractEntityDamageByEntity {

    public Agni() {
        super("agni", "&b火神的愤怒", Material.IRON_SWORD);
    }

    @Override
    public String[] getLore() {
        return new String[] {
                "&7几率 &a75% &7使目标燃烧 &a4 &7秒!",
                "&7几率 &a25% &7使自身燃烧 &a4 &7秒!"
        };
    }

    @Override
    protected void onDamage(EntityDamageByEntityEvent event, Player player, LivingEntity entity) {
        int value = (int) (Math.random() * 100);
        int chance = value <= 25 ? 0 : value > 25 ? 1 : -1; // 几率 15 自身, 25 目标, 否则为 -1 什么不做

        if(chance == -1) return; // 为 -1 则什么也不发生
        if(chance == 0) player.setFireTicks(4 * 20); // 为 0 比较脸黑, 自身燃烧
        else entity.setFireTicks(4 * 20); // 为 1 比较幸运, 目标燃烧
    }
}
